import time


def rapid_recognize(image, ocr_engine, table_engine):
    start_time = time.time()  # 记录开始时间
    # OCR
    rapid_ocr_output = ocr_engine(image, return_word_box=True)
    ocr_result = list(
        zip(rapid_ocr_output.boxes, rapid_ocr_output.txts, rapid_ocr_output.scores)
    )

    # 表格结构识别
    table_results = table_engine(image, ocr_result)

    html_str = table_results.pred_html
    print(html_str)

    end_time = time.time()  # 记录结束时间
    elapsed_time = end_time - start_time  # 计算执行时间
    print(f"函数执行时间: {elapsed_time} 秒")

    return html_str
